package edu.hrbu.spring.service.impl;

import edu.hrbu.spring.dao.ActDao;
import edu.hrbu.spring.pojo.Act;
import edu.hrbu.spring.service.ActService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author 徐登宇
 */
@Service
public class ActServiceImpl2 implements ActService {

    @Resource(name = "actDaoImpl")
    ActDao actDao;

    @Override
    public boolean transfer(Integer fromNo, Integer toNo, Integer balance) {
        return false;
    }

    @Override
    // 无论是否有事务，都会开启一个新的事务
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public boolean save(Act act) {

        int i = 0;

        i += actDao.insert(act);

        return i == 1;
    }
}
